﻿@{
    ViewBag.Title = "Select scoring endpoint";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div>
    <div class="row">
        <div class="col-md-12">
            <h2>Please select a <a href="http://azure.microsoft.com/en-us/documentation/articles/machine-learning-retrain-models-programmatically/" target="_blank"> scoring endpoint.</a></h2>
            <p>The will make your scoring web service use your retrained model.</p>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4">Select web service</div>
        <div class="col-md-8"><select class="dropdown" data-bind="options: webServices,optionsText:'Name',value:selectedWebService"></select></div>
    </div>
    <div class="row">
        <div class="col-md-4">Select endpoint <strong>DO NOT choose default</strong></div>
        <div class="col-md-8">
            <div data-bind="visible: selectedWebService">
                <select class="dropdown" data-bind="options: Endpoints,optionsText:'Name',value:selectedEndpoint"></select>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <a href="submit_update" class="btn btn-primary" role="button">Update Scoring Web Service</a>
        </div>
    </div>
</div>

<script type="text/javascript">
    var viewModel = {
        webServices: ko.observableArray(@Html.Raw(@ViewBag.WebServices)),
        selectedWebService : ko.observable(),
        Endpoints : ko.observableArray(),
        selectedEndpoint : ko.observable()
    }
    viewModel.selectedWebService.subscribe(function(webService) {
        viewModel.Endpoints(webService.Endpoints);
        $.cookie("webService_score", webService.Id);
    });
     viewModel.selectedEndpoint.subscribe(function(endpoint) {
        $.cookie("endpoint_score", endpoint.Name);
    });
    ko.applyBindings(viewModel);
</script>